﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using Sebarf.Services.Interfaces;
using Sebastof.Services.Interfaces;

#endregion

namespace Sebastof.Services.Impl {
	/// <summary>
	/// Description of the class
	/// </summary>
	public class DatahandlerService : Service, IObjectSynchronisationService {
		#region Public Properties

		[ServiceRequest(IsOptional = true)]
		private ICachedDataRegistrationService CachedDataRegistrationService { get; set; }

		#endregion

		#region IObjectSynchronisationService Members

		public object MergeObject(string objectKey, object currentObject, object newObject) {
			if (currentObject == null && CachedDataRegistrationService != null) {
				CachedDataRegistrationService.AddOrUpdateCachedValue(objectKey, newObject);
				return newObject;
			}
			//CachedDataRegistrationService.RefreshObject(objectKey, newObject);
			return currentObject;
		}

		public void MarkObjectAsInvalid(string objectKey) {
			if (CachedDataRegistrationService != null) {
				CachedDataRegistrationService.InvalidateObject(objectKey);
			}
		}

		#endregion
	}
}